gdk: Turn GdkGLContext into a GdkDrawContext
authorBenjamin Otte <otte@redhat.com>
Mon, 28 Nov 2016 16:36:37 +0000 (17:36 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 5 Dec 2016 14:02:47 +0000 (15:02 +0100)
gdk/gdkglcontext.c
gdk/gdkglcontextprivate.h
gdk/mir/gdkmirwindowimpl.c
gdk/wayland/gdkglcontext-wayland.c
gdk/win32/gdkglcontext-win32.c
gdk/x11/gdkglcontext-x11.c

index 2717f5d92925ac00e3f23be85afdb6cea0800e68..4521dd08b8ea47a2200c1b2f9b493710ca2d20ad 100644 (file)
@@ -88,8 +88,6 @@
 #include <epoxy/gl.h>
 
 typedef struct {
-  GdkDisplay *display;
-  GdkWindow *window;
   GdkGLContext *shared_context;
 
   int major;
@@ -115,8 +113,6 @@ typedef struct {
 enum {
   PROP_0,
 
-  PROP_DISPLAY,
-  PROP_WINDOW,
   PROP_SHARED_CONTEXT,
 
   LAST_PROP
@@ -126,7 +122,7 @@ static GParamSpec *obj_pspecs[LAST_PROP] = { NULL, };
 
 G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
 
-G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)
 
 static GPrivate thread_current_context = G_PRIVATE_INIT (g_object_unref);
 
@@ -141,8 +137,6 @@ gdk_gl_context_dispose (GObject *gobject)
   if (current == context)
     g_private_replace (&thread_current_context, NULL);
 
-  g_clear_object (&priv->display);
-  g_clear_object (&priv->window);
   g_clear_object (&priv->shared_context);
 
   G_OBJECT_CLASS (gdk_gl_context_parent_class)->dispose (gobject);
@@ -168,34 +162,6 @@ gdk_gl_context_set_property (GObject      *gobject,
 
   switch (prop_id)
     {
-    case PROP_DISPLAY:
-      {
-        GdkDisplay *display = g_value_get_object (value);
-
-        if (display)
-          g_object_ref (display);
-
-        if (priv->display)
-          g_object_unref (priv->display);
-
-        priv->display = display;
-      }
-      break;
-
-    case PROP_WINDOW:
-      {
-        GdkWindow *window = g_value_get_object (value);
-
-        if (window)
-          g_object_ref (window);
-
-        if (priv->window)
-          g_object_unref (priv->window);
-
-        priv->window = window;
-      }
-      break;
-
     case PROP_SHARED_CONTEXT:
       {
         GdkGLContext *context = g_value_get_object (value);
@@ -220,14 +186,6 @@ gdk_gl_context_get_property (GObject    *gobject,
 
   switch (prop_id)
     {
-    case PROP_DISPLAY:
-      g_value_set_object (value, priv->display);
-      break;
-
-    case PROP_WINDOW:
-      g_value_set_object (value, priv->window);
-      break;
-
     case PROP_SHARED_CONTEXT:
       g_value_set_object (value, priv->shared_context);
       break;
@@ -305,38 +263,6 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
 
   klass->realize = gdk_gl_context_real_realize;
 
-  /**
-   * GdkGLContext:display:
-   *
-   * The #GdkDisplay used to create the #GdkGLContext.
-   *
-   * Since: 3.16
-   */
-  obj_pspecs[PROP_DISPLAY] =
-    g_param_spec_object ("display",
-                         P_("Display"),
-                         P_("The GDK display used to create the GL context"),
-                         GDK_TYPE_DISPLAY,
-                         G_PARAM_READWRITE |
-                         G_PARAM_CONSTRUCT_ONLY |
-                         G_PARAM_STATIC_STRINGS);
-
-  /**
-   * GdkGLContext:window:
-   *
-   * The #GdkWindow the gl context is bound to.
-   *
-   * Since: 3.16
-   */
-  obj_pspecs[PROP_WINDOW] =
-    g_param_spec_object ("window",
-                         P_("Window"),
-                         P_("The GDK window bound to the GL context"),
-                         GDK_TYPE_WINDOW,
-                         G_PARAM_READWRITE |
-                         G_PARAM_CONSTRUCT_ONLY |
-                         G_PARAM_STATIC_STRINGS);
-
   /**
    * GdkGLContext:shared-context:
    *
@@ -412,11 +338,14 @@ gdk_gl_context_begin_frame (GdkGLContext   *context,
 {
   GdkGLContextPrivate *priv, *shared_priv;
   GdkGLContext *shared;
+  GdkWindow *window;
   int ww, wh;
 
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
   g_return_if_fail (region != NULL);
 
+  window = gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context));
+
   priv = gdk_gl_context_get_instance_private (context);
   priv->is_drawing = TRUE;
 
@@ -426,8 +355,8 @@ gdk_gl_context_begin_frame (GdkGLContext   *context,
 
   GDK_GL_CONTEXT_GET_CLASS (context)->begin_frame (context, region);
 
-  ww = gdk_window_get_width (priv->window) * gdk_window_get_scale_factor (priv->window);
-  wh = gdk_window_get_height (priv->window) * gdk_window_get_scale_factor (priv->window);
+  ww = gdk_window_get_width (window) * gdk_window_get_scale_factor (window);
+  wh = gdk_window_get_height (window) * gdk_window_get_scale_factor (window);
 
   gdk_gl_context_make_current (shared);
 
@@ -964,7 +893,7 @@ gdk_gl_context_make_current (GdkGLContext *context)
         }
     }
 
-  if (gdk_display_make_gl_context_current (priv->display, context))
+  if (gdk_display_make_gl_context_current (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), context))
     {
       g_private_replace (&thread_current_context, g_object_ref (context));
       gdk_gl_context_check_extensions (context);
@@ -984,11 +913,9 @@ gdk_gl_context_make_current (GdkGLContext *context)
 GdkDisplay *
 gdk_gl_context_get_display (GdkGLContext *context)
 {
-  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-
   g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
 
-  return priv->display;
+  return gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
 }
 
 /**
@@ -1004,11 +931,9 @@ gdk_gl_context_get_display (GdkGLContext *context)
 GdkWindow *
 gdk_gl_context_get_window (GdkGLContext *context)
 {
-  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-
   g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
 
-  return priv->window;
+  return gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context));
 }
 
 /**
@@ -1077,9 +1002,7 @@ gdk_gl_context_clear_current (void)
   current = g_private_get (&thread_current_context);
   if (current != NULL)
     {
-      GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (current);
-
-      if (gdk_display_make_gl_context_current (priv->display, NULL))
+      if (gdk_display_make_gl_context_current (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (current)), NULL))
         g_private_replace (&thread_current_context, NULL);
     }
 }
index 3193e2d0d8e2868e933ffd54be6b99339aeca3fd..2f1bb5e6f302edb4bc1c4e4d7533717afa8e33f1 100644 (file)
@@ -22,6 +22,7 @@
 #define __GDK_GL_CONTEXT_PRIVATE_H__
 
 #include "gdkglcontext.h"
+#include "gdkdrawcontextprivate.h"
 
 G_BEGIN_DECLS
 
@@ -33,12 +34,12 @@ typedef struct _GdkGLContextClass       GdkGLContextClass;
 
 struct _GdkGLContext
 {
-  GObject parent_instance;
+  GdkDrawContext parent_instance;
 };
 
 struct _GdkGLContextClass
 {
-  GObjectClass parent_class;
+  GdkDrawContextClass parent_class;
 
   gboolean (* realize) (GdkGLContext *context,
                         GError **error);
index 87c77e91b2d7221fcebedbe1b37a5ed3f98a8d35..069a6b0c4054a1bf7b89104164810fb5104a128c 100644 (file)
@@ -1584,7 +1584,6 @@ gdk_mir_window_impl_create_gl_context (GdkWindow     *window,
     return NULL;
 
   context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);
index 1763ec7a18b95a5ea96d0394ec88b94486a51301..a57e1e4e1788bddc85bf83adcc669c72d7e6f279 100644 (file)
@@ -408,7 +408,6 @@ gdk_wayland_window_create_gl_context (GdkWindow     *window,
     return NULL;
 
   context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);
index 8da90a31ee5c0a962adf8468ccf37da66835b0f4..12adf73d20259b4e5aa68b0cd638f6ab9207238a 100644 (file)
@@ -749,7 +749,6 @@ _gdk_win32_window_create_gl_context (GdkWindow *window,
   display_win32->gl_hwnd = hwnd;
 
   context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);
index 92aaaf16adfbe5347a0317b9ce626e3e8de278df..66651890a28d5b1c58e0c7d8ef6e383f8c574fc3 100644 (file)
@@ -1226,7 +1226,6 @@ gdk_x11_window_create_gl_context (GdkWindow    *window,
     return NULL;
 
   context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);